package group.igfd.manager.biz.utils;

public class NumberFormatUtil {

    public static String getPercent(Double discount){
        java.text.NumberFormat percentFormat =java.text.NumberFormat.getPercentInstance(); percentFormat.setMaximumFractionDigits(2); //最大小数位数
        percentFormat.setMaximumIntegerDigits(3);//最大整数位数
        percentFormat.setMinimumFractionDigits(0); //最小小数位数
        percentFormat.setMinimumIntegerDigits(1);//最小整数位数
        String dis = percentFormat.format(discount);//自动转换成百分比显示..
        return dis;
    }

    public static void main(String[] args) {
        System.out.println(getPercent(1d));
        System.out.println(getPercent(0.9));
        System.out.println(getPercent(0.01));
    }
}
